Ext.define('PC.view.FormEvento', {
        extend:'Ext.form.Panel',
        id:'FormEvento',
        widget:'widget.FormEvento',
        url:'',
        bodyPadding:10,
        commonItems:[
            {
                xtype:'hiddenfield',
                name:'id',
                value:0
            },
            {
                xtype:'hiddenfield',
                name:'tipoEventoId',
                value:0
            },
            {
                xtype:'hiddenfield',
                name:'porcinoId'
            },
            {
                xtype:'datefield',
                fieldLabel:'Fecha',
                name:'fechaInicio'
            }
//            ,
//            {
//                xtype:'textfield',
//                fieldLabel:'Descripcion',
//                name:'descripcion'
//            }
        ],
        buttons:[
            {
                text:'Reset',
                handler:function () {
                    this.up('form').getForm().reset();
                }
            },
            {
                text:'Submit',
                formBind:true, //only enabled once the form is valid
                disabled:true,
                handler:function () {
                    var form = this.up('form').getForm();
                    if (form.isValid()) {
                        this.up('form').save(Ext.JSON.encode(form.getValues()));
//                    form.submit({
//                        success:function (form, action) {
//                            Ext.Msg.alert('Success', action.result.msg);
//                        },
//                        failure:function (form, action) {
//                            Ext.Msg.alert('Failed', action.result.msg);
//                        }
//                    });
                    }
                }
            }
        ],
        save:function (params) {
            me = this;
            Ext.Ajax.request({
                loadMask:true,
                url:this.url,
                params:params,
                success:function (resp) {
                    me.saved(resp);
                }
            });
        },
        saved:function (resp) {
            //TODO add an listener for save function
            console.log('respuesta del servidor: ' + resp);
        }
    }
);